package indi.zhifa.study2025.class002.shopcenter.controller;

import com.alibaba.cloud.nacos.NacosConfigManager;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import indi.zhifa.study2025.class002.common.web.entity.ann.ZhiFaRestController;
import indi.zhifa.study2025.class002.shopcenter.logic.item.IShopService;
import indi.zhifa.study2025.class002.shopcenter.logic.item.entity.dto.ItemCreateDto;
import indi.zhifa.study2025.class002.shopcenter.logic.item.entity.dto.ItemEditDto;
import indi.zhifa.study2025.class002.shopcenter.logic.item.entity.dto.ItemPageRequest;
import indi.zhifa.study2025.class002.shopcenter.logic.item.entity.vo.ItemVo;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@Slf4j
@Validated
@RequiredArgsConstructor
@RequestMapping(value =  "/api/shop-center")
@ZhiFaRestController
@Tag(name = "商品库存")
public class ItemController {

    private final IShopService mIShopService;

    private NacosConfigManager nacosConfigManager;

    @PostMapping("/onShelve")
    public ItemVo onShelve(@RequestBody ItemCreateDto pItemCreateDto){
        return mIShopService.onShelve(pItemCreateDto);
    }

    @GetMapping("/{id}")
    public ItemVo itemInfo(@PathVariable(name = "id") Long pId){
        return mIShopService.itemInfo(pId);
    }

    @GetMapping("/page")
    public Page<ItemVo> page(@RequestBody ItemPageRequest pItemPageRequest){
        return mIShopService.page(pItemPageRequest);
    }

    @PutMapping("/{id}")
    public ItemVo edit(@PathVariable(name = "id") Long pId,
                       @RequestBody ItemEditDto pItemEditDto){
        return mIShopService.edit(pId, pItemEditDto);
    }


}
